package com.solace.selenium.controller;

import com.alibaba.fastjson.JSONArray;
import com.solace.selenium.entity.JsonResult;
import com.solace.selenium.entity.SysTask;
import com.solace.selenium.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("job")
public class TaskController {
    @Autowired
    TaskService taskService;
    @RequestMapping(value = "schedule")
    public JsonResult schedule(SysTask sysTask) {
        taskService.schedule(sysTask);
        return new JsonResult("OK");
    }
    @RequestMapping(value = "start")
    public JsonResult start() {
        taskService.start();
        return new JsonResult("OK");
    }
    @RequestMapping(value = "stop")
    public JsonResult stop() {
        taskService.stop();
        return new JsonResult("OK");
    }
    @RequestMapping(value = "getTaskAll")
    public JsonResult getTaskAll() {
        List<SysTask> taskAll = taskService.getTaskAll();
        return new JsonResult(taskAll);
    }
    //批量上传
    @RequestMapping(value = "batchUpdate")
    public JsonResult batchUpdate(String data) {
       taskService.batchUpdate(data);
        return new JsonResult("OK");
    }
}
